import java.util.Stack;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
class huiwen {
    public int start = 0, maxLen = 0;
    public void check(String s, int i, int j){
        while (i >=0  && j < s.length() && s.charAt(i) == s.charAt(j)){
            i--;
            j++;
        }
        if (maxLen < j - i){
            start = i + 1;
            maxLen = j - i - 1;
        }
    }

    public String longestPalindrome(String s) {
        int n = s.length();
        for (int i = 0; i < n; i++) {
            check(s, i, i + 1);
            check(s, i, i);
        }
        if (maxLen <= 0){
            return s.substring(0, 1);
        }
        return s.substring(start, start + maxLen);
    }

}
